package org.jkuang.qstar.index.iterator;

import java.util.ArrayList;
import java.util.List;

import org.jkuang.qstar.index.filter.QueryFilter;
import org.jkuang.qstar.index.filter.ResultFilter;

/**
 * 
 * @author jkuang 2012年11月17日
 *
 * @param <T>
 */
public class QueryStatus<T> {
	private int start;

	private int rows;

	private int count;

	private long offset;

	private List<T> result;

	
	private final QueryFilter qfilter;
	
	private final ResultFilter rfilter;


	public QueryStatus(int start, int rows, int count,QueryFilter qfilter, ResultFilter rfilter) {
		this.start = start;
		this.rows = rows;
		this.count = count;
		this.qfilter =qfilter;
		this.rfilter = rfilter;
		
		this.result = new ArrayList<T>(rows);
	}

	public ResultFilter getRFilter() {
		return rfilter;
	}
	
	public QueryFilter getQFilter() {
		return qfilter;
	}

	public List<T> getResult() {
		return this.result;
	}

	public long getOffset() {
		return this.offset;
	}

	public void next() {
		++this.offset;
	}

	public void addOffset(int offset) {
		this.offset += offset;
	}

	public void setOffset(int offset) {
		this.offset = offset;
	}

	public boolean pageFull() {
		return result.size() >= this.rows;
	}

	public void addNode(T node) {
		result.add(node);
	}

	public boolean startAddNode() {
		return this.offset >= this.start;
	}

	public boolean isGetCount() {
		return this.count > offset;
	}

	public int getRows() {
		return this.rows;
	}

	public int getStart() {
		return start;
	}
}
